﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;

using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.Framework.Server.Base;
using ZhimeiSoft.CharmManager.Server.DAL.Interface;

namespace ZhimeiSoft.CharmManager.Server.DAL
{
    public class ScheduleDAL : BaseDal, IScheduleDAL
    {
        #region IScheuleDAL 成员

        public void InsertSchedule(DBEntitySchedule scheduleInfo)
        {
            DbCommand cmdInsert = DB.GetSqlStringCommand(ScheduleDAL_Const.SQL_INSERT_SCHEDULE);
            DB.AddInParameter(cmdInsert, "SALONID", DbType.Int32, scheduleInfo.SALONID);
            DB.AddInParameter(cmdInsert, "SCHEDULENAME", DbType.String, scheduleInfo.SCHEDULENAME);
            DB.AddInParameter(cmdInsert, "SCHEDULETIME", DbType.DateTime, scheduleInfo.SCHEDULETIME);
            DB.AddInParameter(cmdInsert, "SYSTIME", DbType.DateTime, scheduleInfo.SYSTIME);
            DB.AddInParameter(cmdInsert, "STATE", DbType.String, scheduleInfo.STATE);
            DB.AddInParameter(cmdInsert, "SPLANSTARTTIME", DbType.DateTime, scheduleInfo.SPLANSTARTTIME);
            DB.AddInParameter(cmdInsert, "SPLANENDTIME", DbType.DateTime, scheduleInfo.SPLANENDTIME);
            DB.AddInParameter(cmdInsert, "SPLANTIMESTATE", DbType.String, scheduleInfo.SPLANTIMESTATE);
            DB.AddInParameter(cmdInsert, "SPLANMEMO", DbType.String, scheduleInfo.SPLANMEMO);
            DB.AddInParameter(cmdInsert, "SCHEDULETYPE", DbType.String, scheduleInfo.SCHEDULETYPE);
            DB.AddInParameter(cmdInsert, "SPLANEMPLOYEE", DbType.String, scheduleInfo.SPLANEMPLOYEE);
            DB.ExecuteNonQuery(cmdInsert);
        }

        public void DeleteSchedule(DBEntitySchedule scheduleInfo)
        {
            DbCommand cmdDelete = DB.GetSqlStringCommand(ScheduleDAL_Const.SQL_DELETE_SCHEDULE);
            DB.AddInParameter(cmdDelete, "SCHEDUEID", DbType.Int32, scheduleInfo.SCHEDUEID);
            DB.ExecuteNonQuery(cmdDelete);
        }

        public void UpdateSchedule(DBEntitySchedule scheduleInfo)
        {
            DbCommand cmdUpdate = DB.GetSqlStringCommand(ScheduleDAL_Const.SQL_UPDATE_SCHEDULE);
            DB.AddInParameter(cmdUpdate, "SALONID_NEW", DbType.Int32, scheduleInfo.SALONID);
            DB.AddInParameter(cmdUpdate, "SCHEDULENAME_NEW", DbType.String, scheduleInfo.SCHEDULENAME);
            DB.AddInParameter(cmdUpdate, "SCHEDULETIME_NEW", DbType.DateTime, scheduleInfo.SCHEDULETIME);
            DB.AddInParameter(cmdUpdate, "SYSTIME_NEW", DbType.DateTime, scheduleInfo.SYSTIME);
            DB.AddInParameter(cmdUpdate, "STATE_NEW", DbType.String, scheduleInfo.STATE);
            DB.AddInParameter(cmdUpdate, "SPLANSTARTTIME_NEW", DbType.DateTime, scheduleInfo.SPLANSTARTTIME);
            DB.AddInParameter(cmdUpdate, "SPLANENDTIME_NEW", DbType.DateTime, scheduleInfo.SPLANENDTIME);
            DB.AddInParameter(cmdUpdate, "SPLANTIMESTATE_NEW", DbType.String, scheduleInfo.SPLANTIMESTATE);
            DB.AddInParameter(cmdUpdate, "SPLANMEMO_NEW", DbType.String, scheduleInfo.SPLANMEMO);
            DB.AddInParameter(cmdUpdate, "SCHEDULETYPE_NEW", DbType.String, scheduleInfo.SCHEDULETYPE);
            DB.AddInParameter(cmdUpdate, "SPLANEMPLOYEE_NEW", DbType.String, scheduleInfo.SPLANEMPLOYEE);
            DB.AddInParameter(cmdUpdate, "SCHEDUEID", DbType.Int32, scheduleInfo.SCHEDUEID);
            DB.ExecuteNonQuery(cmdUpdate);
        }

        public System.Data.DataSet QueryScheduleState(string scheduleState)
        {
            DbCommand queryComm = DB.GetSqlStringCommand(ScheduleDAL_Const.SQL_QUERY_SCHEDULE_STATE);
            DB.AddInParameter(queryComm, "STATE", DbType.String, scheduleState);
            return DB.ExecuteDataSet(queryComm);
        }

        #endregion
    }
}
